/*
 * @Author: Zeng Hugh
 * @Date: 2019-11-08 13:32:50
 * @Last Modified by: Zeng Hugh
 * @Last Modified time: 2019-11-08 15:32:57
 */

// *****************各通道靶标及CutOff值*******************
// ******************************************************
//         FAM     VIC     ROX     CY5     Quasar705
// ******************************************************
// 管A     HPIV1   HPIV4   229E    HPIV2   内参
//         34       34     34       35     35
// ******************************************************
// 管B     SP      HRSVB   LP      FluB    内参
//         33       35     36       35     35
// ******************************************************
// 管C     HMPV    ADV     NL63    HF      内参
//         34       35     36      32      35
// ******************************************************
// 管D     OC43    HRV     HKU1    MP      内参
//         34      33      35      35      35
// ******************************************************
// 管E     HRSVA    /      BP      HPIV3   内参
//         37       /      35      34      35
// ******************************************************
// 管F     FluA     /      CP       /      内参
//         35       /      35       /      35
// ******************************************************


using RuleJudge.RuleData;
using SLANCommon.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Media;

namespace RuleJudge.Judge
{
   public class RPP : BaseJudge
   {
        /// <summary>
        /// 构造函数，需要定义项目类型，管，通道信息
        /// </summary>

        #region 定义常量：各通道靶标阳性Cutoff值
        // *********************根据各靶标的阳性判断值（参考值）Cutoff进行阴阳性判断***************************
        public const double Flu_A_Cutoff = 35;          // F孔FAM：甲型流感病毒(FluA)
        public const double Flu_B_Cutoff = 35;          // B孔CY5：乙型流感病毒(FluB)
        public const double HPIV1_Cutoff = 34;          // A孔FAM：人副流感病毒1(HPIV-1)
        public const double HPIV2_Cutoff = 35;          // A孔CY5：人副流感病毒2(HPIV-2)
        public const double HPIV3_Cutoff = 34;          // E孔CY5：人副流感病毒3(HPIV-3)
        public const double HPIV4_Cutoff = 34;          // A孔VIC：人副流感病毒4(HPIV-4)
        public const double RSV_A_Cutoff = 37;          // E孔FAM：呼吸道合胞病毒A(RSV-A)
        public const double RSV_B_Cutoff = 35;          // B孔VIC：呼吸道合胞病毒B(RSV-B)
        public const double ADV_Cutoff = 35;            // C孔VIC：腺病毒 ADV
        public const double HRV_Cutoff = 33;            // D孔VIC：鼻病毒 HRV
        public const double CORO_229E_Cutoff = 34;      // A孔ROX：冠状病毒229E(CORO-229E)
        public const double CORO_OC43_Cutoff = 34;      // D孔FAM：冠状病毒OC43(CORO-OC43)
        public const double CORO_NL63_Cutoff = 36;      // C孔ROX：冠状病毒NL63(CORO-NL63)
        public const double CORO_HKU1_Cutoff = 35;      // D孔ROX：冠状病毒HKU1(CORO-HKU1)
        public const double HMPV_Cutoff = 34;           // C孔FAM：偏肺病毒 HMPV
        public const double Bordetella_Cutoff = 35;     // E孔ROX：百日咳杆菌 BP
        public const double Mypoplasma_Cutoff = 35;     // D孔CY5：肺炎支原体 MP
        public const double Chamydiae_Cutoff = 35;      // F孔ROX：肺炎衣原体 CP
        public const double IPC_Cutoff = 35;            // 内参阳性判断参考值
        #endregion

        // 构造函数，需要定义项目类型，管，通道信息
        public RPP()
        {
            Type = EProjectType.AQ;
            TubesNo = new List<int>() {
                1, 1, 1, 1, 1,
                2, 2, 2,
                3, 3, 3, 3,
                4, 4, 4, 4, 4,
                5, 5, 5, 5,
                6, 6, 6 };
            // 注意此处的通道号指使用了某个各反应孔的第几个通道，区别于后面调用数据时的列表下标
            ChannelsNo = new List<int>() { 
                1, 2, 3, 4, 5,
                2, 4, 5,
                1, 2, 3, 5,
                1, 2, 3, 4, 5,
                1, 3, 4, 5,
                1, 3, 5 };
        }

        /// <summary>
        /// 判断逻辑
        /// </summary>
        /// <param name="samples">样本列表</param>
        /// <returns>非空：SLAN会弹出内容信息框，进行提示</returns>

        public override string Judge(List<Sample> samples)
        {
            // 在结果判断之前，先检查是否有需要判断的样本
            if (samples.Count == 0) return "无判断样本！";
            #region 定义并初始化变量(荧光通道，各靶标结论，质控结果等 ^_^ )
            // 荧光通道顺序（注意此顺序作用于List列表下标，反应孔荧光通道未全部使用时，顺序和下标存在不一致情况！）
            int FAM = 0;
            int VIC = 1;
            int ROX = 2;
            int CY5 = 3;
            int QUASAR705 = 4;
            // 质控相关变量
            int Negative_Num = 0;
            int Positive_Num = 0;
            bool Negative_Pass = false;
            bool Leak_Negative_Control = false;
            bool Positive_Pass = false;
            bool Leak_Positive_Control = false;
            #endregion

            // *****************************************************************************************************************************
            #region 阳性质控（对照）
            List<Sample> PositiveList = samples.Where(s => s.Type == SampleType.HighPositive).ToList();   //取出所有“阳性质控”
            if (PositiveList.Count != 0)  //判断是否存在阳性质控
            {
                foreach (Sample sample in PositiveList)
                {
                    if(// 反应管A
                        sample.Tubes[0].Targets[0].Result.Ct <= HPIV1_Cutoff &&
                        sample.Tubes[0].Targets[1].Result.Ct <= HPIV4_Cutoff &&
                        sample.Tubes[0].Targets[2].Result.Ct <= CORO_229E_Cutoff &&
                        sample.Tubes[0].Targets[3].Result.Ct <= HPIV2_Cutoff &&
                        // sample.Tubes[0].Targets[4].Result.Ct <= IPC_Cutoff &&
                        // 反应管B
                        sample.Tubes[1].Targets[0].Result.Ct <= RSV_B_Cutoff &&
                        sample.Tubes[1].Targets[1].Result.Ct <= Flu_B_Cutoff &&
                        // sample.Tubes[1].Targets[2].Result.Ct <= IPC_Cutoff &&
                        // 反应管C
                        sample.Tubes[2].Targets[0].Result.Ct <= HMPV_Cutoff &&
                        sample.Tubes[2].Targets[1].Result.Ct <= ADV_Cutoff &&
                        sample.Tubes[2].Targets[2].Result.Ct <= CORO_NL63_Cutoff &&
                        // sample.Tubes[2].Targets[3].Result.Ct <= IPC_Cutoff &&
                        // 反应管D
                        sample.Tubes[3].Targets[0].Result.Ct <= CORO_OC43_Cutoff &&
                        sample.Tubes[3].Targets[1].Result.Ct <= HRV_Cutoff &&
                        sample.Tubes[3].Targets[2].Result.Ct <= CORO_HKU1_Cutoff &&
                        sample.Tubes[3].Targets[3].Result.Ct <= Mypoplasma_Cutoff &&
                        // sample.Tubes[3].Targets[4].Result.Ct <= IPC_Cutoff &&
                        // 反应管E
                        sample.Tubes[4].Targets[0].Result.Ct <= RSV_A_Cutoff &&
                        sample.Tubes[4].Targets[1].Result.Ct <= Bordetella_Cutoff &&
                        sample.Tubes[4].Targets[2].Result.Ct <= HPIV3_Cutoff &&
                        // sample.Tubes[4].Targets[3].Result.Ct <= IPC_Cutoff &&
                        // 反应管F
                        sample.Tubes[5].Targets[0].Result.Ct <= Flu_A_Cutoff &&
                        sample.Tubes[5].Targets[1].Result.Ct <= Chamydiae_Cutoff
                        // sample.Tubes[5].Targets[2].Result.Ct <= IPC_Cutoff
                    )
                    {
                        sample.Conclusion.Add(new Conclusion() { Content = "阳性质控：符合要求", Color=Colors.Green, BackgroundColor=Colors.LightGreen });
                        Positive_Num = Positive_Num + 1;
                    }
                    else
                    {
                        sample.Conclusion.Add(new Conclusion() { Content = "阳性质控：不符合要求", Color = Colors.Blue, BackgroundColor = Colors.LightYellow });
                    }
                }
                if(PositiveList.Count == Positive_Num)
                    {
                        Positive_Pass = true;
                    }
            }
            //在一次实验中未设置阳性质控，则给与提示
            else
            {
                Positive_Pass = true;
                Leak_Positive_Control = true;
            }
            #endregion

            // *****************************************************************************************************************************
            #region 阴性质控（对照）
            List<Sample> NegativeList = samples.Where(s => s.Type == SampleType.Negative).ToList();   //取出所有“阴性质控”
            if (NegativeList.Count != 0)  //判断是否存在阳性质控
            {
                foreach (Sample sample in NegativeList)
                {
                    if (// 反应管A
                        sample.Tubes[0].Targets[0].Result.Ct > HPIV1_Cutoff &&
                        sample.Tubes[0].Targets[1].Result.Ct > HPIV4_Cutoff &&
                        sample.Tubes[0].Targets[2].Result.Ct > CORO_229E_Cutoff &&
                        sample.Tubes[0].Targets[3].Result.Ct > HPIV2_Cutoff &&
                        sample.Tubes[0].Targets[4].Result.Ct <= IPC_Cutoff &&
                        // 反应管B
                        sample.Tubes[1].Targets[0].Result.Ct > RSV_B_Cutoff &&
                        sample.Tubes[1].Targets[1].Result.Ct > Flu_B_Cutoff &&
                        sample.Tubes[1].Targets[2].Result.Ct <= IPC_Cutoff &&
                        // 反应管C
                        sample.Tubes[2].Targets[0].Result.Ct > HMPV_Cutoff &&
                        sample.Tubes[2].Targets[1].Result.Ct > ADV_Cutoff &&
                        sample.Tubes[2].Targets[2].Result.Ct > CORO_NL63_Cutoff &&
                        sample.Tubes[2].Targets[3].Result.Ct <= IPC_Cutoff &&
                        // 反应管D
                        sample.Tubes[3].Targets[0].Result.Ct > CORO_OC43_Cutoff &&
                        sample.Tubes[3].Targets[1].Result.Ct > HRV_Cutoff &&
                        sample.Tubes[3].Targets[2].Result.Ct > CORO_HKU1_Cutoff &&
                        sample.Tubes[3].Targets[3].Result.Ct > Mypoplasma_Cutoff &&
                        sample.Tubes[3].Targets[4].Result.Ct <= IPC_Cutoff &&
                        // 反应管E
                        sample.Tubes[4].Targets[0].Result.Ct > RSV_A_Cutoff &&
                        sample.Tubes[4].Targets[1].Result.Ct > Bordetella_Cutoff &&
                        sample.Tubes[4].Targets[2].Result.Ct > HPIV3_Cutoff &&
                        sample.Tubes[4].Targets[3].Result.Ct <= IPC_Cutoff &&
                        // 反应管F
                        sample.Tubes[5].Targets[0].Result.Ct > Flu_A_Cutoff &&
                        sample.Tubes[5].Targets[1].Result.Ct > Chamydiae_Cutoff &&
                        sample.Tubes[5].Targets[2].Result.Ct <= IPC_Cutoff)
                    {
                        sample.Conclusion.Add(new Conclusion() { Content = "阴性质控：符合要求", Color = Colors.Green, BackgroundColor = Colors.LightGreen });
                        Negative_Num = Negative_Num + 1;
                    }
                    else
                    {
                        sample.Conclusion.Add(new Conclusion() { Content = "阴性质控：不符合要求", Color = Colors.Blue, BackgroundColor = Colors.LightYellow });
                    }
                }
                if (NegativeList.Count == Negative_Num)
                {
                    Negative_Pass = true;
                }
            }
            //在一次实验中未设置阳性质控，则给与提示
            else
            {
                Negative_Pass = true;
                Leak_Negative_Control = true;
            }
            #endregion

            // ****************************************************************************************************************************
            #region 待测样本判读
            List<Sample> UnknownList = samples.Where(s => s.Type == SampleType.Unknown).ToList();   //取出所有“待测样本”
            foreach (Sample sample in UnknownList)
            {
                // 每个样本6个反应孔，每个反应孔FAM，VIC，ROX，CY5为靶标荧光通道，QUASAR705为内参荧光通道
                bool IPC_Block_A = false;
                bool IPC_Block_B = false;
                bool IPC_Block_C = false;
                bool IPC_Block_D = false;
                bool IPC_Block_E = false;
                bool IPC_Block_F = false;

                // 内参判读规则：
                //（1）孔内任一通道为阳性，则内参不管是否扩增均符合要求；
                //（2）孔内任一通道为阴性，则内参必须正常扩增；
                //（3）同一样本的六个孔内参结果都符合要求，则进行样本结果判读。

                // A孔内参结果 副流感病毒1，副流感病毒4，冠状病毒229E，副流感病毒2
                #region IPC_Block_A
                if ((sample.Tubes[0].Targets[0].Result.Ct <= HPIV1_Cutoff) ||
                    (sample.Tubes[0].Targets[1].Result.Ct <= HPIV4_Cutoff) ||
                    (sample.Tubes[0].Targets[2].Result.Ct <= CORO_229E_Cutoff) ||
                    (sample.Tubes[0].Targets[3].Result.Ct <= HPIV2_Cutoff) ||
                    (sample.Tubes[0].Targets[4].Result.Ct <= IPC_Cutoff))
                {
                    IPC_Block_A = true;
                }
                else 
                {
                    sample.Tubes[0].Targets[4].Conclusion.Add(new Conclusion
                    {
                        Content = "内参不合格",
                        Color = Colors.Blue,
                        BackgroundColor = Colors.LightYellow,
                    });
                }
                #endregion

                // B孔内参结果 肺炎链球菌，呼吸道合胞病毒B，嗜肺军团菌，乙型流感病毒
                #region IPC_Block_B
                if ((sample.Tubes[1].Targets[0].Result.Ct <= RSV_B_Cutoff) ||
                    (sample.Tubes[1].Targets[1].Result.Ct <= Flu_B_Cutoff) ||
                    (sample.Tubes[1].Targets[2].Result.Ct <= IPC_Cutoff))
                {
                    IPC_Block_B = true;
                }
                else
                {
                    sample.Tubes[1].Targets[2].Conclusion.Add(new Conclusion
                    {
                        Content = "内参不合格",
                        Color = Colors.Blue,
                        BackgroundColor = Colors.LightYellow,
                    });
                }
                #endregion

                // C孔内参结果 偏肺病毒，腺病毒，冠状病毒NL63，流感嗜血杆菌
                #region IPC_Block_C
                if ((sample.Tubes[2].Targets[0].Result.Ct <= HMPV_Cutoff) ||
                    (sample.Tubes[2].Targets[1].Result.Ct <= ADV_Cutoff) ||
                    (sample.Tubes[2].Targets[2].Result.Ct <= CORO_NL63_Cutoff) ||
                    (sample.Tubes[2].Targets[3].Result.Ct <= IPC_Cutoff))
                {
                    IPC_Block_C = true;
                }
                else
                {
                    sample.Tubes[2].Targets[3].Conclusion.Add(new Conclusion
                    {
                        Content = "内参不合格",
                        Color = Colors.Blue,
                        BackgroundColor = Colors.LightYellow,
                    });
                }
                #endregion

                // D孔内参结果 冠状病毒OC43，鼻病毒，冠状病毒HKU1，肺炎衣原体
                #region IPC_Block_D
                if ((sample.Tubes[3].Targets[0].Result.Ct <= CORO_OC43_Cutoff) ||
                    (sample.Tubes[3].Targets[1].Result.Ct <= HRV_Cutoff) ||
                    (sample.Tubes[3].Targets[2].Result.Ct <= CORO_HKU1_Cutoff) ||
                    (sample.Tubes[3].Targets[3].Result.Ct <= Mypoplasma_Cutoff) ||
                    (sample.Tubes[3].Targets[4].Result.Ct <= IPC_Cutoff))
                {
                    IPC_Block_D = true;
                }
                else
                {
                    sample.Tubes[3].Targets[4].Conclusion.Add(new Conclusion
                    {
                        Content = "内参不合格",
                        Color = Colors.Blue,
                        BackgroundColor = Colors.LightYellow,
                    });
                }
                #endregion

                // E孔内参结果 呼吸道合胞病毒A，百日咳杆菌，副流感病毒3
                #region IPC_Block_E
                if ((sample.Tubes[4].Targets[0].Result.Ct <= RSV_A_Cutoff) ||
                    (sample.Tubes[4].Targets[1].Result.Ct <= Bordetella_Cutoff) ||
                    (sample.Tubes[4].Targets[2].Result.Ct <= HPIV3_Cutoff) ||
                    (sample.Tubes[4].Targets[3].Result.Ct <= IPC_Cutoff))
                {
                    IPC_Block_E = true;
                }
                else
                {
                    sample.Tubes[4].Targets[3].Conclusion.Add(new Conclusion
                    {
                        Content = "内参不合格",
                        Color = Colors.Blue,
                        BackgroundColor = Colors.LightYellow,
                    });
                }
                #endregion

                // F孔内参结果 甲型流感病毒，肺炎支原体
                #region IPC_Block_F
                if ((sample.Tubes[5].Targets[0].Result.Ct <= Flu_A_Cutoff) ||
                    (sample.Tubes[5].Targets[1].Result.Ct <= Chamydiae_Cutoff) ||
                    (sample.Tubes[5].Targets[2].Result.Ct <= IPC_Cutoff))
                {
                    IPC_Block_F = true;
                }
                else
                {
                    sample.Tubes[5].Targets[2].Conclusion.Add(new Conclusion
                    {
                        Content = "内参不合格",
                        Color = Colors.Blue,
                        BackgroundColor = Colors.LightYellow,
                    });
                }
                #endregion

                if (IPC_Block_A && IPC_Block_B && IPC_Block_C && IPC_Block_D && IPC_Block_E && IPC_Block_F)
                {
                    #region 管A：副流感病毒HPIV1、副流感病毒HPIV4、冠状病毒229E、副流感病毒HPIV2
                    // 副流感病毒HPIV1
                    bool HPIV1 = sample.Tubes[0].Targets[0].Result.Ct <=HPIV1_Cutoff;
                    /*
                    sample.Tubes[0].Targets[0].Conclusion.Add(new Conclusion
                    {
                        Content = HPIV1 ? "副流感病毒HPIV1阳性" : "副流感病毒HPIV1阴性",
                        Color = HPIV1 ? Colors.Red : Colors.Green,
                        BackgroundColor = HPIV1 ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 副流感病毒HPIV4
                    bool HPIV4 = sample.Tubes[0].Targets[1].Result.Ct <= HPIV4_Cutoff;
                    /*
                    sample.Tubes[0].Targets[1].Conclusion.Add(new Conclusion
                    {
                        Content = HPIV4 ? "副流感病毒HPIV4阳性" : "副流感病毒HPIV4阴性",
                        Color = HPIV4 ? Colors.Red : Colors.Green,
                        BackgroundColor = HPIV4 ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 冠状病毒229E
                    bool CORO_229E = sample.Tubes[0].Targets[2].Result.Ct <= CORO_229E_Cutoff;
                    /*
                    sample.Tubes[0].Targets[2].Conclusion.Add(new Conclusion
                    {
                        Content = CORO_229E ? "冠状病毒229E阳性" : "冠状病毒229E阴性",
                        Color = CORO_229E ? Colors.Red : Colors.Green,
                        BackgroundColor = CORO_229E ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 副流感病毒HPIV2
                    bool HPIV2 = sample.Tubes[0].Targets[3].Result.Ct <= HPIV2_Cutoff;
                    /*
                    sample.Tubes[0].Targets[3].Conclusion.Add(new Conclusion
                    {
                        Content = HPIV2 ? "副流感病毒HPIV2阳性" : "副流感病毒HPIV2阴性",
                        Color = HPIV2 ? Colors.Red : Colors.Green,
                        BackgroundColor = HPIV2 ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    #endregion

                    #region 管B：合胞病毒HRSVB、乙型流感病毒FluB
                    // 合胞病毒HRSVB
                    bool HRSVB = sample.Tubes[1].Targets[0].Result.Ct <= RSV_B_Cutoff;
                    /*
                    sample.Tubes[1].Targets[0].Conclusion.Add(new Conclusion
                    {
                        Content = HRSVB ? "合胞病毒HRSVB阳性" : "合胞病毒HRSVB阴性",
                        Color = HRSVB ? Colors.Red : Colors.Green,
                        BackgroundColor = HRSVB ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 流感病毒FluB
                    bool FluB = sample.Tubes[1].Targets[1].Result.Ct <= Flu_B_Cutoff;
                    /*
                    sample.Tubes[1].Targets[1].Conclusion.Add(new Conclusion
                    {
                        Content = FluB ? "乙型流感病毒FluB阳性" : "乙型流感病毒FluB阴性",
                        Color = FluB ? Colors.Red : Colors.Green,
                        BackgroundColor = FluB ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    #endregion

                    #region 管C：偏肺病毒HMPV、腺病毒ADV、冠状病毒NL63
                    // 偏肺病毒HMPV
                    bool HMPV = sample.Tubes[2].Targets[0].Result.Ct <= HMPV_Cutoff;
                    /*
                    sample.Tubes[2].Targets[0].Conclusion.Add(new Conclusion
                    {
                        Content = HMPV ? "偏肺病毒HMPV阳性" : "偏肺病毒HMPV阴性",
                        Color = HMPV ? Colors.Red : Colors.Green,
                        BackgroundColor = HMPV ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 腺病毒ADV
                    bool ADV = sample.Tubes[2].Targets[1].Result.Ct <= ADV_Cutoff;
                    /*
                    sample.Tubes[2].Targets[1].Conclusion.Add(new Conclusion
                    {
                        Content = ADV ? "腺病毒ADV阳性" : "腺病毒ADV阴性",
                        Color = ADV ? Colors.Red : Colors.Green,
                        BackgroundColor = ADV ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 冠状病毒NL63
                    bool CORO_NL63 = sample.Tubes[2].Targets[2].Result.Ct <= CORO_NL63_Cutoff;
                    /*
                    sample.Tubes[2].Targets[2].Conclusion.Add(new Conclusion
                    {
                        Content = CORO_NL63 ? "冠状病毒NL63阳性" : "冠状病毒NL63阴性",
                        Color = CORO_NL63 ? Colors.Red : Colors.Green,
                        BackgroundColor = CORO_NL63 ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    #endregion

                    #region 管D：冠状病毒OC43、鼻病毒HRV、冠状病毒HKU1、肺炎支原体MP
                    // 冠状病毒OC43
                    bool CORO_OC43 = sample.Tubes[3].Targets[0].Result.Ct <= CORO_OC43_Cutoff;
                    /*
                    sample.Tubes[3].Targets[0].Conclusion.Add(new Conclusion
                    {
                        Content = CORO_OC43 ? "冠状病毒OC43阳性" : "冠状病毒OC43阴性",
                        Color = CORO_OC43 ? Colors.Red : Colors.Green,
                        BackgroundColor = CORO_OC43 ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 鼻病毒HRV
                    bool HRV = sample.Tubes[3].Targets[1].Result.Ct <= HRV_Cutoff;
                    /*
                    sample.Tubes[3].Targets[1].Conclusion.Add(new Conclusion
                    {
                        Content = HRV ? "鼻病毒HRV阳性" : "鼻病毒HRV阴性",
                        Color = HRV ? Colors.Red : Colors.Green,
                        BackgroundColor = HRV ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 冠状病毒HKU1
                    bool CORO_HKU1 = sample.Tubes[3].Targets[2].Result.Ct <= CORO_HKU1_Cutoff;
                    /*
                    sample.Tubes[3].Targets[2].Conclusion.Add(new Conclusion
                    {
                        Content = CORO_HKU1 ? "冠状病毒HKU1阳性" : "冠状病毒HKU1阴性",
                        Color = CORO_HKU1 ? Colors.Red : Colors.Green,
                        BackgroundColor = CORO_HKU1 ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 肺炎支原体MP
                    bool Mypoplasma = sample.Tubes[3].Targets[3].Result.Ct <= Mypoplasma_Cutoff;
                    /*
                    sample.Tubes[3].Targets[3].Conclusion.Add(new Conclusion
                    {
                        Content = Mypoplasma ? "肺炎支原体MP阳性" : "肺炎支原体MP阴性",
                        Color = Mypoplasma ? Colors.Red : Colors.Green,
                        BackgroundColor = Mypoplasma ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    #endregion

                    #region 管E：合胞病毒HRSVA、百日咳杆菌BP、副流感病毒HPIV3
                    // 合胞病毒HRSVA
                    bool HRSVA = sample.Tubes[4].Targets[0].Result.Ct <= RSV_A_Cutoff;
                    /*
                    sample.Tubes[4].Targets[0].Conclusion.Add(new Conclusion
                    {
                        Content = HRSVA ? "合胞病毒HRSVA阳性" : "合胞病毒HRSVA阴性",
                        Color = HRSVA ? Colors.Red : Colors.Green,
                        BackgroundColor = HRSVA ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 百日咳杆菌BP
                    bool Bordetella = sample.Tubes[4].Targets[1].Result.Ct <= Bordetella_Cutoff;
                    /*
                    sample.Tubes[4].Targets[1].Conclusion.Add(new Conclusion
                    {
                        Content = Bordetella ? "百日咳杆菌BP阳性" : "百日咳杆菌BP阴性",
                        Color = Bordetella ? Colors.Red : Colors.Green,
                        BackgroundColor = Bordetella ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 副流感病毒HPIV3
                    bool HPIV3 = sample.Tubes[4].Targets[2].Result.Ct <= HPIV3_Cutoff;
                    /*
                    sample.Tubes[4].Targets[2].Conclusion.Add(new Conclusion
                    {
                        Content = HPIV3 ? "副流感病毒HPIV3阳性" : "副流感病毒HPIV3阴性",
                        Color = HPIV3 ? Colors.Red : Colors.Green,
                        BackgroundColor = HPIV3 ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    #endregion

                    #region 管F: 甲型流感病毒FluA、肺炎衣原体CP
                    // 甲型流感病毒FluB
                    bool FluA = sample.Tubes[5].Targets[0].Result.Ct <= Flu_B_Cutoff;
                    /*
                    sample.Tubes[5].Targets[0].Conclusion.Add(new Conclusion
                    {
                        Content = FluA ? "甲型流感病毒FluA阳性" : "甲型流感病毒FluA阴性",
                        Color = FluA ? Colors.Red : Colors.Green,
                        BackgroundColor = FluA ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    // 肺炎衣原体CP
                    bool Chamydiae = sample.Tubes[5].Targets[1].Result.Ct <= Chamydiae_Cutoff;
                    /*
                    sample.Tubes[5].Targets[1].Conclusion.Add(new Conclusion
                    {
                        Content = Chamydiae ? "肺炎衣原体CP阳性" : "肺炎衣原体CP阴性",
                        Color = Chamydiae ? Colors.Red : Colors.Green,
                        BackgroundColor = Chamydiae ? Colors.LightCoral : Colors.LightGreen,
                    });
                    */
                    #endregion

                    // 病原体多分型合并
                    bool HPIV = HPIV1 || HPIV2 || HPIV3 || HPIV4; // 副流感病毒1，2，3，4(HPIV-1,HPIV-2,HPIV-3,HPIV-4)
                    bool HRSV = HRSVA || HRSVB; // 呼吸道合胞病毒A，B
                    bool CORO = CORO_229E || CORO_HKU1 || CORO_NL63 || CORO_OC43; // 冠状病毒229E，OC43，NL63，HKU1
                    // 定义结论字符串
                    string Flu_A_Str = FluA ? "甲型流感病毒阳性；" : "";
                    string Flu_B_Str = FluB ? "乙型流感病毒阳性；" : "";
                    string HPIV_Str = (HPIV1 ? "人副流感病毒1型阳性；" : "") + (HPIV2 ? "人副流感病毒2型阳性；" : "") + (HPIV3 ? "人副流感病毒3型阳性；" : "") + (HPIV4 ? "人副流感病毒4型阳性；" : "");
                    string HRSV_Str = HRSV ? "呼吸道合胞病毒阳性；" : "";
                    string CORO_Str = CORO ? "冠状病毒阳性；" : "";
                    string HRV_Str = HRV ? "鼻病毒阳性；" : "";
                    string ADV_Str = ADV ? "腺病毒阳性；" : "";
                    string HMPV_Str = HMPV ? "偏肺病毒阳性；" : "";
                    string Bordetella_Str = Bordetella ? "百日咳杆菌阳性；" : "";
                    string Mypoplasma_Str = Mypoplasma ? "肺炎支原体阳性；" : "";
                    string Chamydiae_Str = Chamydiae ? "肺炎衣原体阳性；" : "";
                    #region 样本结论
                    if (FluA || FluB || HPIV || HRSV || CORO || HRV || ADV || HMPV || Mypoplasma || Chamydiae || Bordetella)
                    {
                        string Result_Text = Flu_A_Str + Flu_B_Str + HPIV_Str + HRSV_Str + CORO_Str + HRV_Str + ADV_Str + HMPV_Str + Mypoplasma_Str + Chamydiae_Str + Bordetella_Str;
                        string[] Result_arr = Result_Text.Split('；');
                        string Result_Conclusion = string.Empty;

                        if (Result_arr.Length <= 4)
                        {
                            Result_Conclusion = string.Join("；", Result_arr);
                        }
                        if ((Result_arr.Length > 4) && (Result_arr.Length <= 8))
                        {
                            Result_Conclusion = string.Join("；", Result_arr.Take(4).ToArray()) + "；\n" + string.Join("；", Result_arr.Skip(4).Take(Result_arr.Length - 4).ToArray());
                        }
                        if (Result_arr.Length > 8)
                        {
                            Result_Conclusion = string.Join("；", Result_arr.Take(4).ToArray()) + "；\n" + string.Join("；", Result_arr.Skip(4).Take(4).ToArray()) + "；\n" + string.Join("；", Result_arr.Skip(8).Take(Result_arr.Length - 8).ToArray());
                        }
                        sample.Conclusion.Add(new Conclusion() { Content = Result_Conclusion, Color=Colors.Red, BackgroundColor=Colors.LightCoral});
                    }
                    else
                    {
                        sample.Conclusion.Add(new Conclusion() { Content = "阴性", Color = Colors.Green, BackgroundColor = Colors.LightGreen });
                    }
                    #endregion
                }
                else
                {
                    sample.Conclusion.Add(new Conclusion() { Content = "无结果", Color = Colors.Blue, BackgroundColor = Colors.LightYellow });
                }
            }
            #endregion

            // ****************************************************************************************************************
            #region 质控结果异常（不合格，缺失）提示

            if (!Negative_Pass || !Positive_Pass)
            {
                MessageBox.Show("一个或多个阴阳性质控不符合要求！是否忽略？", "质控提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            if (Leak_Negative_Control || Leak_Positive_Control)
            {
                MessageBox.Show("实验缺少阴性质控或阳性质控！是否忽略？", "质控提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            #endregion

            return string.Empty;
        }
    }
}